package LeetCode;

public class LC_070_ClimbingStairs {
    public static void main(String[] args) {

    }

    static class Solution {
        public int climbStairs(int n) {
            int[] flags = new int[n + 1];
            for (int i = 0; i <= n; i++)
                flags[i] = -1;
            return climbStairs(flags, n);
        }

        private int climbStairs(int[] flags, int n) {
            if (flags[n] != -1)
                return flags[n];
            if (n == 1 || n == 0) {
                flags[n] = 1;
                return 1;
            } else {
                flags[n] = climbStairs(flags, n - 1) + climbStairs(flags, n - 2);
                return flags[n];
            }
        }
    }
}
